<template>
  <div>
    <examine-detail
      :formOptions="formOptions"
      :modelValue="formValue"
      :formSectionList="formSectionList"
      :isPreview="isPreviewList"
    ></examine-detail>
  </div>
</template>
  <script setup>
import { onMounted, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { useRoute, useRouter } from 'vue-router'
import listMixins from '@/hooks/useList'
import examineDetail from './components/examineDetail.vue'
import { getTempInfoApi } from '@/api/common'
import { ERR_OK } from 'config/statusCode'

let { formOptions, gridClick } = listMixins()
const props = defineProps({
  componentObject: {
    // 返回的对象值
    type: Object,
    default() {
      return {}
    }
  }
})
const $route = useRoute()
const router = useRouter()
const { t } = useI18n()

const formSectionList = ref([])
const isPreviewList = {
  baseInfo: true,
  selectTemplate: true,
  reviewPanel: true,
  examineTable: false
}
const templateCode = ref('')

const formValue  = ref({...props.componentObject})
// formValue.value.KPI_BASIC.examineTypeCn = "2222"
onMounted(() => {
  templateCode.value = formValue.value.tmplCode || "new_assessment"
  handelDetail()
})

// 详情
const handelDetail = async () => {
  // 请求接口
  await initTemp()
}

// 模版
const initTemp = async () => {
  const { code, data } = await getTempInfoApi(templateCode.value, '')
//   console.log(66, data)
  const temp = data.formSectionVOList.find((item) => item.code == 'SPAEBO.ASSESSMENT_TEMPLATE')
  if (temp) {
    temp.title = '评估设置'
    temp.stepName = '评估设置'
  }
  if (code == ERR_OK) {
    formSectionList.value = data.formSectionVOList.filter((item) => {
      // 考核明细中 考核不涉及评级不展示最终评级和推荐评级
      if (item.code == 'SPAEBO.ASSESSMENT_DETAILS' && !formValue.value.gradeRatingFlag) {
        item.formTemplateFieldVOList &&
          item.formTemplateFieldVOList.map((val) => {
            // 最终评级
            if ($route.query.isGradeRatingFlag == 'false') {
              if (val.fieldCode == 'finalGradeRuleContentName' || val.fieldCode == 'recommendGradeRuleContentName') {
                val.displayPage = ''
              }
            }
          })
      }
      // 过滤考核对象
      return item.code == 'SPAEBO.LOCAL_BASIC' || item.code == 'SPAEBO.ASSESSMENT_DETAILS'
    })
    console.log(67, formSectionList.value)
  }
}

</script>
  <style lang="scss" scoped></style>
  